
#ifndef __STDDEFS_H__
#define __STDDEFS_H__

#include "stdTypes.h"
#include "apiBridge.h"


//=========================================================================
/* DEBUG */
#define DEBUG_CONSOLE
// #define DEBUG_FILE

//=========================================================================

// these probably won't work with big-endian devices
#define RGB_GET_BLUE(c)               ( (uint8) ( ( c ) & 0xffu ) )
#define RGB_GET_GREEN(c)                 ( (uint8) ( ( c >> 8 ) & 0xffu ) )
#define RGB_GET_RED(c)               ( (uint8) ( ( c >> 16 ) & 0xffu ) )
#define RGB_GET_ALPHA(c)                ( (uint8) ( ( c >> 24 ) & 0xffu ) )

#define RGB_SET_BLUE(c,v)             ( c = c & ( ~0xffu ) | ( (v) & 0xffu ) )
#define RGB_SET_GREEN(c,v)               ( c = c & ~( 0xffu << 8 ) | ( ( (v) & 0xffu ) << 8 ) )
#define RGB_SET_RED(c,v)             ( c = c & ~( 0xffu << 16 ) | ( ( (v) & 0xffu ) << 16 ) )
#define RGB_SET_ALPHA(c,v)              ( c = c & ~( 0xffu << 24 ) | ( ( (v) & 0xffu ) << 24 ) )


//////////////////////////////////////////////////////////////////////////////
// Byte Alignment
//////////////////////////////////////////////////////////////////////////////
//
// Most Brew hardware seems to like structs aligned on 4 byte boundaries.
// The "ZAS = -zas4" ARM compiler option specifies this in makefiles.
// The PC compilers generally seem to default to 2 byte boundaries and
// the emulator is ok with it.
// For loading binary data straight into structs, it is safest to use the
// alignment boundary of the most strict of the target devices.
//
#define BITS_PER_BYTE                   8
#define	STD_BYTE_ALIGNMENT_INTERVAL		4

#define LENGTH(array)	( sizeof(array) / sizeof(array[0]) )

#endif